import { ref } from 'vue'
import { defineStore } from 'pinia'

export const useAppStore = defineStore('app', () => {
  // token
  const token = ref('')
  function setToken(t: string) {
    token.value = t
    localStorage.setItem('token', t)
  }

  // expend
  const isCollapse = ref(false)
  function toggleSidebar() {
    isCollapse.value = !isCollapse.value
  }

  // ready
  const isReady = ref(false)
  function setReady() {
    isReady.value = true
  }

  return {
    token,
    setToken,
    isCollapse,
    toggleSidebar,
    isReady,
    setReady
  }
})
